# -*- coding: utf-8 -*-
from enum import Enum
from app.models.model import *


def code(enum):
    return enum.value[0]


def decription(enum):
    return enum.value[1]


def mapping(enum):
    cont = {}
    for e in enum:
        cont[e.name] = {'key': e.value[0], 'desc': e.value[1]}
    return cont


def name_by_key(enum, key):
    for e in enum:
        if e.value[0] == key:
            return e.value[1]


def named(code, sign, type, piece, uuid):
    return '''%s_%s_%s_%s_%s''' % (code, sign, type, piece, uuid)


class Loosened(Enum):
    """松散岩类"""
    Overburden = ('XTFG', '覆盖土')
    Loess = ('XTHT', '黄土')
    Clay = ('XT00', '粘土')
    SandyClay = ('XTSZ', '砂质粘土')
    CalcareousClay = ('XTGZ', '钙质粘土')
    GravellyClay = ('XTHL', '含砾粘土')
    FillingSoil = ('XTTC', '填充土')
    Sand = ('XS00', '砂')
    CoarseSand = ('XS01', '粗砂')
    MediumSand = ('XS02', '中砂')
    FineSand = ('XS03', '细砂')
    SiltySand = ('XS04', '粉砂')
    Gravel = ('XLLS', '砾石')
    Breccia = ('XLJL', '角砾')
    CoarseGravel = ('XLSL', '砂砾')
    FineGravel = ('XLXL', '细砾')
    Galangal = ('XTSJ', '砂姜')


class Sandstone(Enum):
    """砂岩类"""
    Coarse = ('S100', '粗砂岩')
    Medium = ('S200', '中砂岩')
    Fine = ('S300', '细砂岩')
    Siltstone = ('S400', '粉砂岩')
    Argillaceous = ('S0NZ', '泥质砂岩')
    Ferruginous = ('S0TZ', '铁质砂岩')
    Asphaltic = ('S0LQ', '含沥青质砂岩')
    Tuffaceous = ('S0NH', '凝灰质砂岩')
    Quartz = ('S0SY', '石英砂岩')
    Arkose = ('S0CS', '长石砂岩')
    Gravelly = ('S0HL', '含砾砂岩')
    PeliticPowder = ('S4NZ', '泥质粉砂岩')
    FerrousPowder = ('S4TZ', '铁质粉砂岩')
    CarbonaceousPowder = ('S4TA', '碳质粉砂岩')
    TuffaceousPowder = ('S4NH', '凝灰质粉砂岩')


class Conglomerate(Enum):
    """砾岩类"""
    Boulder = ('L000', '巨砾岩')
    Cobbles = ('L100', '粗砾岩')
    Meso = ('L200', '中砾岩')
    Fine = ('L300', '细砾岩')
    Quartz = ('L0SY', '石英砾岩')
    Sandy = ('L0SZ', '砂质砾岩')
    Silty = ('L0FS', '粉砂质砾岩')
    Argillaceous = ('L0NZ', '泥质砾岩')
    Tuffaceous = ('L0NH', '凝灰质砾岩')


class Breccia(Enum):
    """角砾岩类"""
    Coarse = ('J100', '粗角砾岩')
    Medium = ('J200', '中角砾岩')
    Fine = ('J300', '细角砾岩')
    Volcanic = ('J0HS', '火山角砾岩')
    Sandy = ('J0SZ', '砂质角砾岩')
    Silty = ('J0FS', '粉砂质角砾岩')
    Argillaceous = ('J0NZ', '泥质角砾岩')
    Tuffaceous = ('J0NH', '凝灰质角砾岩')


class Mudstone(Enum):
    """泥岩类"""
    Mudstone = ('N000', '泥岩')
    Calcareous = ('N0HZ', '灰质泥岩')
    Silty = ('N0FS', '粉砂质泥岩')
    Aluminous = ('N0LU', '铝质泥岩')
    Carbonaceous = ('N0TA', '碳质泥岩')
    Sandy = ('N0SZ', '砂质泥岩')
    Ferruginous = ('N0TZ', '铁质泥岩')
    Siliceous = ('N0GZ', '硅质泥岩')
    Tuffaceous = ('N0NH', '凝灰质泥岩')
    Kaolinite = ('N0GL', '高岭石泥岩')
    Bituminous = ('N0LQ', '含沥青泥岩')
    Piebald = ('N0HB', '花斑状泥岩')


class Shale(Enum):
    """页岩类"""
    Shale = ('I000', '页岩')
    Carbonaceous = ('I0HT', '含碳页岩')
    Carbonaceouse = ('I0TA', '碳质页岩')
    Sandy = ('I0SZ', '砂质页岩')
    Aluminous = ('I0LU', '铝质页岩')
    Oil = ('I0HY', '含油页岩')


class Limestone(Enum):
    """灰岩类"""
    Limestone = ('H000', '灰岩')
    Breccia = ('H0JL', '角砾灰岩')
    Argillaceous = ('H0NZ', '泥质灰岩')
    Asphaltene = ('H0LQ', '沥青质灰岩')
    Grain = ('H0KL', '颗粒灰岩')
    Biodetritus = ('H0SW', '生物屑灰岩')
    Reef = ('H0J0', '礁灰岩')
    Oolitic = ('H0EZ', '鲕状灰岩')
    Algae = ('H0Z0', '藻灰岩')
    BambooLeaf = ('H0ZY', '竹叶状灰岩')
    Piebald = ('H0HB', '花斑状灰岩')
    Coagulation = ('H0N0', '凝灰岩')


class Dolomite(Enum):
    """白云岩类"""
    Dolomite = ('Y100', '白云岩')
    Reef = ('Y1J0', '礁白云岩')
    Oolitic = ('Y1EZ', '鲕状白云岩')
    Algae = ('Y1Z0', '藻白云岩')
    Breccia = ('Y1JL', '角砾状白云岩')


class Mineral(Enum):
    """矿产类"""
    Bauxite = ('K0LU', '铝土矿')
    Siderite = ('K0LT', '菱铁矿')
    Hematite = ('K0CT', '赤铁矿')
    Limonite = ('K0HE', '褐铁矿')
    Pyrite = ('K0HT', '黄铁矿')
    RockSalt = ('K0YY', '岩盐')
    Gypsum = ('K0SG', '石膏')
    Sylvite = ('K0JY', '钾盐层')
    Magnesium = ('K0MY', '镁盐层')
    Borax = ('K0PS', '硼砂层')
    Mirabilite = ('K0MX', '芒硝层')
    Petroleum = ('K0SY', '石油层')
    Cretaceous = ('K0BE', '白垩层')
    Diatomite = ('K0GZ', '硅藻土')
    NaturalGas = ('K0TR', '天然气层')


class Coal(Enum):
    """煤"""
    Coal = ('M000', '煤')
    DirtBand = ('MG00', '夹矸')
    NaturalCoke = ('M0TR', '天然焦')
    Argillaceous = ('M0NT', '泥碳')
    Lignite = ('M0HM', '褐煤s')
    Long = ('M0CY', '长烟煤')
    Gas = ('M0QM', '气煤')
    GasFat = ('M0QF', '气肥煤')
    Fat = ('M0FM', '肥煤')
    Coking = ('M0JM', '焦煤')
    Lean = ('M0SM', '瘦煤')
    MeagerLean = ('M0PS', '贫瘦煤')
    Meager = ('M0PM', '贫煤')


class Magma(Enum):
    """岩浆岩"""
    Granite = ('A0HG', '花岗岩')
    Diorite = ('A0SC', '闪长岩')
    Porphyry = ('A0B1', '斑岩')
    Pyroxene = ('A0H0', '辉岩')
    Diabase = ('A0H1', '辉绿岩')
    Porphyrite = ('A0B2', '玢岩')
    Lamprophyre = ('A0HB', '煌斑岩')
    Rhyolite = ('A0LW', '流纹岩')
    Andesite = ('A0AS', '安山岩')
    Dacite = ('A0AY', '英安岩')
    Trachyte = ('A0CM', '粗面岩')
    Basalt = ('A0XW', '玄武岩')
    Peridotite = ('A0G1', '橄榄岩')
    GranitePorphyry = ('A0H2', '花岗斑岩')
    Granodiorite = ('A0HS', '花岗闪长岩')
    DioritePorphyry = ('A0SB', '闪长斑岩')
    QuartzDiorite = ('A0SS', '石英闪长岩')
    DiabasePorphyrite = ('A0HI', '辉绿玢岩')
    Syenite = ('A0ZC', '正长岩')
    Monzonite = ('A0EC', '二长岩')
    Gabbro = ('A0HC', '辉长岩')
    Igneous = ('A000', '火成岩')


class MixedMetamorphic(Enum):
    # 混合岩类
    Migmatite = ('B0H1', '混合岩')
    Slate = ('B0B0', '板岩')
    Phyllite = ('B0QM', '千枚岩')
    Schist = ('B0P0', '片岩')
    Gneiss = ('B0PM', '片麻岩')
    Quartzite = ('B0SY', '石英岩')
    Hornfels = ('B0JI', '角页岩')
    Marble = ('B0DL', '大理岩')
    Wollastonite = ('B0GH', '硅灰岩')
    Corundum = ('B0GY', '刚玉岩')
    Mylonite = ('B0ML', '糜棱岩')


class AgeSystem(Enum):
    """年代(系)"""
    Quaternary = ('Q', '第四系')
    Neogene = ('N', '新近系')
    Paleogene = ('E', '古近系')
    Cretaceous = ('K', '白垩系')
    Jurassic = ('J', '侏罗系')
    Triassic = ('T', '三叠系')
    Permian = ('P', '二叠系')
    Carboniferous = ('C', '石炭系')
    Devonian = ('D', '泥盆系')
    Silurian = ('S', '志留系')
    Ordovician = ('O', '奥陶系')
    Cambrian = ('H', '寒武系')
    Sinian = ('Z', '震旦系')


class AgeSeries(Enum):
    """年代(统)"""
    NO = (0, '不分统')
    Down = (1, '下')
    Mid = (2, '中')
    Up = (3, '上')


class AgeGroup(Enum):
    """年代(组)"""
    Shiqianfeng = ('Q', '石千峰组')
    UpperShihezi = ('S', '上石盒子组')
    LowerShihezi = ('X', '下石盒子组')
    Shanxi = ('J', '山西组')
    Taiyuan = ('T', '太原组')
    Benxi = ('B', '本溪组')


class Lithology(Enum):
    """岩性字母对应表"""
    Unconformity = ('D', '不整合')
    Disconformity = ('F', '假整合')
    Conformity = ('T', '整合')
    Loose = ('X', '松散岩')
    Sandstone = ('S', '砂岩')
    Conglomerate = ('L', '砾岩')
    Breccia = ('J', '角砾岩')
    Mudstone = ('N', '泥岩')
    Limestone = ('H', '灰岩')
    Dolomite = ('Y', '白云岩')
    Ore = ('K', '矿岩')
    Coal = ('M', '煤')
    Magma = ('A', '岩浆岩')
    MixedMetamorphic = ('B', '混合与变质岩')


class Sign(Enum):
    """标志层"""
    MA = ('MA', '1号煤')
    MB = ('MB', '2号煤')
    MC = ('MC', '3号煤')
    MD = ('MD', '4号煤')
    ME = ('ME', '5号煤')
    MF = ('MF', '6号煤')
    MG = ('MG', '7号煤')
    MH = ('MH', '8号煤')
    MI = ('MI', '9号煤')
    MJ = ('MJ', '10号煤')
    MK = ('MK', '11号煤')
    ML = ('ML', '12号煤')
    MM = ('MM', '13号煤')
    MN = ('MN', '14号煤')
    MO = ('MO', '15号煤')
    MP = ('MP', '16号煤')
    MQ = ('MQ', '17号煤')
    MR = ('MR', '18号煤')
    MS = ('MS', '19号煤')
    MT = ('MT', '20号煤')
    MU = ('MU', '21号煤')
    MV = ('MV', '22号煤')
    MW = ('MW', '23号煤')
    MX = ('MX', '24号煤')
    MY = ('MY', '25号煤')
    MZ = ('MZ', '26号煤')


class MapType(Enum):
    """矿图类型编码"""
    A = ('A', '采掘类')
    B = ('B', '地测及防治水类')
    C = ('C', '机电类')
    D = ('D', '运输类')
    E = ('E', '通风类')
    F = ('F', '安全类')
    G = ('G', '柱状、剖面')
    # Z = ('Z', '其它')


class MapAssembly(Enum):
    """矿图组件"""
    # A-采掘类
    CJ = ('CJ', '采掘工程平面图')
    HD = ('HD', '巷道布置图')
    CC = ('CC', '井底车场平面图')
    JT = ('JT', '井筒断面图')
    # B-地测及防治水类
    QD = ('QD', '区域地形图')
    DD = ('DD', '矿井地形地质图')
    SD = ('SD', '矿井分水平地形地质图')
    GC = ('GC', '工业广场平面图')
    DZ = ('DZ', '井上、下对照图')
    MZ = ('MZ', '主要保护煤柱图')
    YQ = ('YQ', '矿井涌水量与各种相关因素动态曲线图')
    CL = ('CL', '煤层底板等高线及资源储量估算图')
    SW = ('SW', '水文地质图')
    CS = ('CS', '矿井充水性图')
    DX = ('DX', '井下导线网图')
    GZ = ('GZ', '工作面地质图')
    # C-机电类
    JD = ('JD', '机电设备布置图')
    GP = ('GP', '供/排水系统图')
    GD = ('GD', '供电系统图')
    # D-运输类
    YS = ('YS', '井下运输系统图')
    # E-通风类
    TF = ('TF', '通风系统图')
    WL = ('WL', '通风网络示意图')
    WC = ('WC', '瓦斯抽采系统图')
    FH = ('FH', '防灭火系统图')
    FC = ('FC', '防尘系统图')
    WD = ('WD', '瓦斯地质图')
    # F-安全类
    AJ = ('AJ', '安全监测装备布置图')
    TX = ('TX', '井下通信系统图')
    RY = ('RY', '人员定位系统图')
    FY = ('FY', '压风自救系统图')
    BZ = ('BZ', '井下避灾路线图')
    SJ = ('SJ', '供水施救系统图')
    # G-柱状、剖面
    ZZ = ('ZZ', '供水施救系统图')
    MD = ('MD', '矿井煤岩层柱状对比图')
    KP = ('KP', '矿井勘探线剖面图')
    SZ = ('SZ', '矿井综合水文地质柱状图')
    SP = ('SP', '矿井水文地质剖面图')
    MS = ('MS', '分煤层损失量计算图')
    GS = ('GS', '工作面损失量计算图')
    DG = ('DG', '矿井地质构造纲要图')


class MapType2Assembly(Enum):
    A = ('A', [
        ('CJ', '采掘工程平面图'),
        ('HD', '巷道布置图'),
        ('CC', '井底车场平面图'),
        ('JT', '井筒断面图')
    ])
    B = ('B', [
        ('QD', '区域地形图'),
        ('DD', '矿井地形地质图'),
        ('SD', '矿井分水平地形地质图'),
        ('GC', '工业广场平面图'),
        ('DZ', '井上、下对照图'),
        ('MZ', '主要保护煤柱图'),
        ('YQ', '矿井涌水量与各种相关因素动态曲线图'),
        ('CL', '煤层底板等高线及资源储量估算图'),
        ('SW', '水文地质图'),
        ('CS', '矿井充水性图'),
        ('DX', '井下导线网图'),
        ('GZ', '工作面地质图')
    ])
    C = ('C', [
        ('JD', '机电设备布置图'),
        ('GP', '供/排水系统图'),
        ('GD', '供电系统图')
    ])
    D = ('D', [
        ('YS', '井下运输系统图')
    ])
    E = ('E', [
        ('TF', '通风系统图'),
        ('WL', '通风网络示意图'),
        ('WC', '瓦斯抽采系统图'),
        ('FH', '防灭火系统图'),
        ('FC', '防尘系统图'),
        ('WD', '瓦斯地质图')
    ])
    F = ('F', [
        ('AJ', '安全监测装备布置图'),
        ('TX', '井下通信系统图'),
        ('RY', '人员定位系统图'),
        ('FY', '压风自救系统图'),
        ('BZ', '井下避灾路线图'),
        ('SJ', '供水施救系统图')
    ])
    G = ('G', [
        ('ZZ', '供水施救系统图'),
        ('MD', '矿井煤岩层柱状对比图'),
        ('KP', '矿井勘探线剖面图'),
        ('SZ', '矿井综合水文地质柱状图'),
        ('SP', '矿井水文地质剖面图'),
        ('MS', '分煤层损失量计算图'),
        ('GS', '工作面损失量计算图'),
        ('DG', '矿井地质构造纲要图')
    ])
    Z = ('Z', [('OT', '其它')])


class TunnelType(Enum):
    """井巷类型"""
    Development = (0, '开拓巷道')
    Preparation = (1, '采准巷道')
    Stoping = (2, '回采巷道')


class GuidePointType(Enum):
    """导线点"""
    Default = (0, '默认')
    GradeChange = (1, '变坡点')
    Inflection = (2, '拐点')
    Intersection = (3, '交叉点')
    Wellhead = (4, '井口')
    Horsehead = (5, '马头门')
    BottomHole = (6, '井底')


class SectionShape(Enum):
    """断面形状"""
    Default = (0, '默认')
    Semicircular = (1, '半圆拱')
    ThreeCore = (2, '三芯拱')
    Rectangle = (3, '矩形')
    Circular = (4, '圆形')
    HighHorseshoe = (5, '高马蹄')
    LowHorseshoe = (6, '低马蹄')


class StructType(Enum):
    """结构类型"""
    WorkingFace = (0, '工作面')
    Fault = (1, '断层')
    Collapse = (2, '陷落柱')
    ReserveBlock = (3, '储量块段')
    PondingArea = (4, '积水区')
    Boundary = (5, '井田边界')
    Zone3 = (6, '三区(可采区、缓采区、禁采区)')
    PillarCode = (7, '煤柱编码')


class StructCode(Enum):
    """结构编码分别对应类型"""
    WorkingFace = (0, '工作面编码')
    Fault = (1, '断层编码')
    Collapse = (2, '陷落柱编码')
    BlockSection = (3, '煤体块段编码')
    PondingArea = (4, '积水区编码')
    Boundary = (5, '井田边界编码')
    Zone3 = (6, '三区编码')
    PillarCode = (7, '煤柱编码')


class WorkingFaceType(Enum):
    """工作面类型"""
    Default = (0, '默认')
    Driving = (1, '掘进')
    Stoping = (2, '回采')
    Goaf = (3, '采空')
    GoafPonding = (4, '采空积水')


class WorkingFaceCode(Enum):
    """采区工作面编码"""
    MiningArea = ('☆☆', '采区编码')
    WorkingFace = ('△△', '工作面编码')


class DrivingTechnology(Enum):
    """掘进工艺"""
    Comprehensive = (0, '综掘')
    Machine = (1, '机掘')
    Cannon = (2, '炮掘')


class ThreeArea(Enum):
    """三区类型"""
    Minable = (0, '可采区')
    Slow = (1, '缓采区')
    Forbidden = (2, '禁采区')


class FaultType(Enum):
    """断层类型"""
    Normal = (0, '正断层')
    Reverse = (1, '逆断层')
    FlatThrust = (2, '平推断层')


class DiscType(Enum):
    """盘面类型"""
    Up = (0, '上盘')
    Down = (1, '下盘')


class HoleInclinationMethod(Enum):
    """孔斜计算法"""
    Midpoint = (0, '中点法(省缺)')
    AverageHole = (1, '平均孔段法')


class EquipmentSystem(Enum):
    """设备系统"""
    PowerSupply = (0, '供电系统')
    WaterSupply = (1, '供水系统')
    AirSupply = (2, '供风系统')
    Drainage = (3, '排水系统')
    Grouting = (4, '注浆系统')
    Pumping = (5, '抽放系统')
    Communication = (6, '通讯系统')


class MonitorSensorType(Enum):
    """检测设备类型"""
    MonitorSensor = (0, '监测传感器')
    PersonnelSensor = (1, '人员监测分站')
    PositionCard = (2, '定位卡')


class MonitorObject(Enum):
    """监控对象"""
    MiningArea = (0, '采区')
    CoalWorkingFace = (1, '采煤工作面')
    DrivingWorkingFace = (2, '掘进工作面')
    BlindAlley = (3, '盲巷')
    Goaf = (4, '采空区')


class PipelineType(Enum):
    """线路及管道中心线类型"""
    Default = (0, '默认')
    GradeChange = (1, '变坡点')
    Inflection = (2, '拐点')
    Intersection = (3, '交叉点')


class BoundaryType(Enum):
    """井田类型"""
    CenterPoint = (0, '中心点')
    InflectionPoint = (1, '拐点')
    BorderPoints = (2, '边界点')


class Sensor(Enum):
    # 0XX: 代表瓦斯传感器
    CH4 = ('001', '甲烷')
    WS = ('002', '风速')
    MS0 = ('003', '微震传感器')
    CO = ('004', '一氧化碳')
    CO2 = ('005', '二氧化碳')
    O2 = ('006', '氧气')
    T = ('007', '温度')
    FD = ('008', '馈电')
    GC = ('009', '瓦斯含量')
    GO = ('010', '瓦斯突出')
    # 1XX: 顶板/冲击地压
    SR = ('101', '支架阻力')
    RAM = ('102', '顶板离层仪')
    AF = ('103', '锚索测力仪')
    LR = ('104', '激光测距')
    RML = ('105', '顶板移近量')
    CE = ('106', '立柱伸缩')
    SI = ('107', '支架倾角')
    HS = ('108', '钻孔应力')
    MS1 = ('109', '微震传感器')
    ER = ('110', '电磁辐射')
    DCP = ('111', '钻屑测点')
    ERP = ('112', '电磁辐射测点')
    # 2XX: 水害
    LHP = ('201', '长钻孔测点')
    SWP = ('202', '供水量测点')
    DWP = ('203', '排水量测点')
    WSP = ('204', '水仓测点')
    AWP = ('205', '密闭墙测点')
    RFP = ('206', '降雨量测点')


class SensorStatus(Enum):
    Normal = ('0', '无状态')
    Success = ('1', '正常')
    Warning = ('2', '故障')
    Fail = ('3', '报警')
    Invalid = ('4', '未启用/失效')


class Model(Enum):
    # Mine = MineModel
    Meta = MetaModel
    Header = HeaderModel
    Layer = LayerModel
    Style = StyleModel
    Dimstyle = DimstyleModel
    Linetype = LinetypeModel
    Viewport = ViewportModel
    Layout = LayoutModel
    LWPOLYLINE = LWPolylineModel
    TEXT = TextModel
    Insert = InsertModel
    MTEXT = MTextModel
    LINE = LineModel
    ELLIPSE = EllipseModel
    HATCH = HatchModel
    CIRCLE = CircleModel
    ARC = ArcModel
    Spline = SplineModel
    Solid = SolidModel
    Point = PointModel
    Polyline = PolylineModel
    Dimension = DimensionModel
    # Boundary = BoundaryModel
    # Track = TrackModel
    # Position = PositionModel
    # Tunnel = TunnelModel
    # GuidePoint = GuidePointModel
    # Fault = FaultModel
    # Warning = WarningModel
    # Workingface = WorkingfaceModel
    # Driving = DrivingModel
    # Recovery = RecoveryModel
    # Waterlogged = WaterloggedModel
    # ThreeArea = ThreeAreaModel
    # CoalPillar = CoalPillarModel
    # Collapse = CollapseModel
    # DrillIndex = DrillIndexModel
    # DrillHole = DrillHoleModel
    # DrillLayer = DrillLayerModel
    # DrillingResult = DrillingResultModel
    # Equipment = EquipmentModel
    # Monitor = MonitorModel
    # Pipeline = PipelineModel
    # PipelineXY = PipelineXYModel
    # TinIndex = TinIndexModel
    # TinStructure = TinStructureModel
    # TinPoint = TinPointModel
    # CoalRegion = CoalRegionModel
    # CoalNature = CoalNatureModel
    # GasNature = GasNatureModel
    # CoalPoint = CoalPointModel
    # CoalPointLayer = CoalPointLayerModel


class Error(Enum):
    """
        错误码:
        头两位为业务编码,后三位为错误码
        如 0x01000 - 01为图纸管理,001未找到图纸
    """
    # 0x00###: 共通操作相关
    No = (0x00000, '正常返回')
    NotData = (0x00001, '存储记录不存在。')
    # 0x01###: 图档操作相关
    NotMeta = (0x01001, '数据库中未找到图纸。')
    FmtError = (0x01002, '数据库存储格式错误。')
    # 0x02###: 数据库相关
    PositionExist = (0x02001, '当前编号的定位分站已存在。')
    # 0x03###: 数据库相关
    KJ236Error = (0x03001, 'KJ236数据连接失败。')


class ValkyrjaException(Exception):
    def __init__(self, error: Error):
        super().__init__(self)
        self.error = error

    def error(self):
        return self.error
